import { instance, unwrap } from './utils'

export async function listCars(params?: API.PageReq) {
  const res = await instance.post<API.Res<Data[]>>('/car/carInfo/getCarInfoList', null, { params })

  return unwrap(res)
}

export async function addCar(data: API.Req) {
  const res = await instance.post<API.Res<Data>>('/car/carInfo/addCarInfo', data)

  return unwrap(res)
}

export async function putCar(data: API.Req) {
  const res = await instance.post<API.Res<Data>>('/car/carInfo/editCarInfo', data)

  return unwrap(res)
}

export async function delCar(id: number | string) {
  const res = await instance.post<API.Res<Data>>('/car/carInfo/deleteCarInfo', null, { params: { ID: id } })

  return unwrap(res)
}
